class Constraint < ActiveRecord::Base

 def self.getValueByKeyAndTime(thiskey,thistime)
   thisconstraintobj = Constraint.find(:first,
                           :conditions => ["(`key` LIKE ?) AND (((start_time < ?) OR (start_time IS NULL)) AND ((end_time > ?) OR (end_time IS NULL)))", thiskey, thistime, thistime],
                           :order => "priority DESC")
   if thisconstraintobj.nil?
     raise "unspecified constraint #{thiskey}"
   else
     return thisconstraintobj.value
   end
 end

end
